import { Message } from 'element-ui';
export function testPicType(file) {
  const typeArr = ['image/png', 'image/jpeg', 'image/gif', 'image/jpg'];
  const isPic = typeArr.includes(file.type);
  if (!isPic) {
    Message.error('上传头像图片只能是GIF、JPG、JPEG、PNG格式!');
  }
  return isPic;
}
export function testPicSize(file, size, name) {
  const result = file.size / 1024 < size;
  // eslint-disable-next-line no-undef
  const sizeStr = size > 1024 ? _.floor(size / 1024) + 'M' : size + 'KB';
  if (!result) {
    Message.error(`上传${name}图片大小不能超过 ${sizeStr}!`);
  }
  return result;
}
